import moment from 'moment'

/**
 * 最近2天
 */
export const rangeLast2Days = () => {
	const now = new Date();
	const start = moment(now).subtract(1,'days').startOf('day').toDate();
	const end = moment(now).endOf('day').toDate();
	return [start, end];
}

/**
 * 最近一周
 */
export const rangeLast1Weeks = () => {
	const now = new Date();
	const start = moment(now).subtract(1,'weeks').add(1, "days").startOf('day').toDate();
	const end = moment(now).endOf('day').toDate();
	return [start, end];
}

/**
 * 最近两周
 */
export const rangeLast2Weeks = () => {
	const now = new Date();
	const start = moment(now).subtract(2, 'weeks').add(1, "days").startOf('day').toDate();
	const end = moment(now).endOf('day').toDate();
	return [start, end];
}

/**
 * 最近一个月
 */
export const rangeLast1Month= () => {
	const now = new Date();
	const start = moment(now).subtract(1, 'months').add(1, "days").startOf('day').toDate();
	const end = moment(now).endOf('day').toDate();
	return [start, end];
}

/**
 * 最近三个月
 */
export const rangeLast3Month= () => {
	const now = new Date();
	const start = moment(now).subtract(3, 'months').add(1, "days").startOf('day').toDate();
	const end = moment(now).endOf('day').toDate();
	return [start, end];
}

export const rangeStartToEndDay= (startDate, endDate) => {
	const start = moment(startDate).add(1,'days').startOf('day').toDate();
	const end = moment(endDate).subtract(1,'days').endOf('day').toDate();
	return [start, end];
}

export default {
	rangeLast2Days,
	rangeLast1Weeks,
	rangeLast2Weeks,
	rangeLast1Month,
	rangeLast3Month,
    rangeStartToEndDay
}
